import { Component } from '@angular/core';
import { AdatokService } from '../adatok.service';
import { map } from 'rxjs';

@Component({
  selector: 'app-about',
  templateUrl: './about.component.html',
  styleUrls: ['./about.component.css']
})
export class AboutComponent {
  visszajott_adatok?:any;
  sorokSzama?:number;

  constructor(private db:AdatokService){
    this.sorokLekerese();
  }

  sorokLekerese(): void {
                          this.db.getAllAdatok().snapshotChanges().pipe
                          (
                            map(
                                  changes =>
                                  changes.map(c =>
                                                (
                                                  { key: c.payload.key, ...c.payload.val() }
                                                )
                                            )
                              )
                          )
                          .subscribe
                                    (
                                      (data:any):void => {
                                                            this.visszajott_adatok = data;
                                                            console.log(this.visszajott_adatok);
                                                            this.sorokSzama=this.visszajott_adatok.length;
                                                            console.log(this.sorokSzama);
                                                          }
                                    );
                        }

}
